﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>精品课程管理</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
       @Html.Partial("~/Views/Share/PublicTopNav2.cshtml")
        <div class="container">
            <div class="row">
                <h1 class="topTitle-h1">康复治疗微课程网络学习平台<br>
                    <small>广州中医药大学康复治疗微课程网络学习平台</small></h1>
            </div>
        </div>
        @*导航菜单*@
        @Html.Partial("~/Views/Share/PublicAdminNaviMenu.cshtml", 1)
        <div class="container mainwrap">
            <div class="row">
                <div class="col-xs-2">
                    <div class="dropdown theme-dropdown clearfix">
                        <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                            <li class="active" role="presentation">
                                <a role="menuitem" tabindex="-1" href="javascript:void(0)">
                                    <span class="glyphicon glyphicon-list"></span>课程列表</a></li>
                            <li role="presentation" class="divider"></li>
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1" href="@Url.Action("CourseInfoAdd", "CourseInfo")">
                                    <span class="glyphicon glyphicon-plus"></span>新建课程</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-xs-10">
                    <div class="panel panel-default mainwrap-part">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                <ol class="breadcrumb">
                                    <li>精品课程管理</li>
                                    <li class="active">课程列表</li>
                                </ol>
                            </h3>
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <form class="form-horizontal" role="form">
                                    <div class="form-group clearfix">
                                        <label class="control-label col-xs-2">课程名称:</label>
                                        <div class="col-xs-2">
                                            <input type="text" id="courseNameSearchTxt" class="form-control input-md" placeholder="请输入课程名称" />
                                        </div>
                                        <label class="control-label col-xs-2">是否停用:</label>
                                        <div class="col-xs-2">
                                            <select id="isStopSearchSel" class="form-control">
                                                <option>请选择</option>
                                                <option value="false">否</option>
                                                <option value="true">是</option>
                                            </select>
                                        </div>
                                        <div class="col-xs-4">
                                            <button type="button" onclick="getList(1)" class="btn btn-success btn-md"><span class="glyphicon glyphicon-search"></span>搜索 </button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                            <div class="row">
                                <table class="table table-bordered tb1 table-striped table-hover">
                                    <thead>
                                        <tr>
                                            <th width="20%">课程名称</th>
                                            <th width="10%">课程类型</th>
                                            <th width="10%">学分</th>
                                            <th width="20%">创建时间</th>
                                            <th width="10%">是否停用</th>
                                            <th width="30%">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tbody">
                                    </tbody>
                                </table>
                            </div>
                            <div class="row clearfix well d-page">
                                <div id="PagInfo" class="pull-left sum">
                                </div>
                                <div class="clearfix pull-right">
                                    <ul id="PageTool" class="pagination">
                                    </ul>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        @Html.Partial("~/Views/Share/PublicFooter.cshtml")
        @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script>
        $(function () {
            var options = false;
            var _state = false;

            if (!!window.location.hash) {
                var _hash = window.location.hash.substr(1);
                getList(_hash);
            } else {
                getList(1);
            }
        })
        
        $(function () {
            $(window).scroll(function () {
                if ($(window).scrollTop() >= 300) {
                    $('.actGotop').fadeIn(300);
                } else {
                    $('.actGotop').fadeOut(300);
                }
            });
            $('.actGotop').click(function () {
                $('html,body').animate({ scrollTop: '0px' }, 800);
            });
        });

        function statusChange(id) {
            $.easyPost("/CourseInfo/CourseStatuesChange", { "Id": id },
              function (data) {
                  if (!data.result) {
                      showTips.open(data.message);
                      return;
                  }
                  if (!!window.location.hash) {
                      var _hash = window.location.hash.substr(1);
                      getList(_hash);
                  } else {
                      getList(1);
                  }
              }, "json");
        }

        function getList(pageNo) {
            var tbody = $("#tbody");
            var _courseName = $("#courseNameSearchTxt").val();
            var _isStop = $("#isStopSearchSel").val();
            $("#PagInfo").html("");
            $("#PageTool").html("");

            $.easyPost("/CourseInfo/GetCourseInfoList", { "PageNO": pageNo, "PageSize": "10", "CourseName": _courseName, "IsStop": _isStop },
               function (data) {
                   if (!data.result) {
                       showTips.open(data.message);
                       return;
                   }
                   var _html = '';
                   if (data.rows.length > 0) {
                       $(".d-page").show();

                       var _row = data.rows,
                           _rowL = _row.length;
                       options = {
                           totalPages: data.totalPage,
                           total: data.total,
                           currentPage: pageNo,
                           onPageClicked: function (event, originalEvent, type, page) {
                               getList(page);
                           }
                       }
                       initialPaginator(options, "PageTool", "PagInfo");

                       for (var i = 0; i < _rowL; i++) {
                           var item = _row[i];
                           var _date = item.CreateTime.toString().replace(/\//g, "");
                           var time = eval('new ' + _date);
                           var isStop;
                           if (item.IsStop) {
                               isStop = '是';
                           }
                           else {
                               isStop = '否';
                           }
                           _html += "<tr>";
                           _html += "<td>" + item.CourseName + "</td>";
                           _html += "<td>" + item.CourseType + "</td>";
                           _html += "<td>" + item.CreditPoint + "</td>";
                           _html += "<td>" + time.format('yyyy-MM-dd') + "</td>";
                           _html += "<td>" + isStop + "</td>";
                           _html += "<td>";
                           _html += "<a href='javascript:void(0)' onclick='statusChange(\"" + item.Id + "\")' class='operate'><span class='glyphicon glyphicon-stop'></span> " + (item.IsStop ? "启用" : "停用") + "</a>";
                           _html += "<a href='/CourseInfo/CourseInfoEdit?Id=" + item.Id + "' class='operate'><span class='glyphicon glyphicon-pencil'></span> 编辑</a>";
                           _html += "<a href='/CourseInfo/AssignTeacher?Id=" + item.Id + "' class='operate'><span class='glyphicon glyphicon-pencil'></span> 分配教师</a>";
                           _html += "</td>";
                           _html += "</tr>";
                       }
                   }
                   else {
                       _html = "<tr><td colspan='6' align='center'>暂无内容!</tr>";
                       $(".d-page").hide();
                   }
                   tbody.html(_html);
               }, "json");
        }
    </script>
</body>
</html>
